var session = sessionStorage.getItem("session");
var currentgroupid = 0;
var initSel; //初始化选中项；
if (!session) {
	window.parent.location = "../../login.html";
}
$(function() {
	$.ajax({
		url: IP + "GetSystemParam?&callback=?&flag=1001" + "&session" + session,
		type: "Get",
		dataType: "jsonp",
		jsonp: "callback",
		jsonpCallback: "resultHandler",
		success: function(data) {
			var options = data.vValue.split(",");
			initSel = options[0];
			var sel = [];
			for (var i = 0; i < options.length; i++) {
				var n = [];
				n.push(options[i]);
				switch (options[i]) {
					case "Ping":
						n.push("Ping测试");
						break;
					case "TcpPing":
						n.push("TcpPing测试");
						break;
					case "NsLookUp":
						n.push("DNS测试");
						break;
					case "TraceRoute":
						n.push("路由追踪");
						break;

					case "FtpDownload":
						n.push("FTP下载");
						break;
					case "FtpUpload":
						n.push("FTP上传");
						break;
					case "WebDownload":
						n.push("网页浏览");
						break;
					case "HttpDownload":
						n.push('网页下载');
						break;
					case "RetrieveEmail":
						n.push("邮件接收");
						break;
					case "SendEmail":
						n.push("邮件发送");
						break;
					case "视频测试":
						n.push("视频测试");
						break;
				};
				sel.push(n);
			}
			$("#testType").combobox({
				data: sel,
				valueField: 0,
				textField: 1,
				editable: false,
				onSelect: function() {
					change()
				}
			})
			AddRow();
		}
	});
	//加载测试参数列表

	//加载测试组列表
	$("#taskGroupList").jqGrid({
		url: IP + "GetSigleParamGroupInfo?callback=?&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			align: "center",
			key: true,
			width: 50,
			hidden: true,
		}, {
			label: '参数组名称',
			name: 'paramGroup',
			width: 90,
			align: "center",
		}, {
			label: '创建人',
			name: 'cPreson',
			width: 70,
			align: "center",
		}, {
			label: '类型',
			name: 'type',
			align: "center",
			width: 70
		}, {
			label: '创建时间',
			name: 'cTime',
			width: 70
		}, {
			label: '备注',
			name: 'meno',
			width: 70
		}],
		loadonce: true,
		viewrecords: true,

		rowNum: 15,
		rownumbers: true,
		autowidth: true,
		page: 1,
		loadtext: '正在加载数据',
		pager: "#taskGroupListPager",
		onSelectRow: function(id) {
			$("#paramGroup").textbox("disable");
			$("#showType").val("0");
			currentgroupid = id;
			change(); // 选中行后执行列表查找				 
		},
	})
	var h = $("body").height();
	$("#taskGroupList").jqGrid("setGridHeight", h - 200)
	var template2 = {
		"groupOp": "AND",
		"rules": [{
			"field": "paramGroup",
			"op": "eq",
			"data": "W"
		}, {
			"field": "count",
			"op": "le",
			"data": "15"
		}]
	};
	// activate the build in search with multiple option
	$('#testTypeList').navGrid("#testTypeListPager", {
			search: true, // show search button on the toolbar
			add: false,
			edit: false,
			del: false,
			refresh: true
		}, {}, // edit options
		{}, // add options
		{}, // delete options
		{
			multipleSearch: true,
			multipleGroup: true,
			showQuery: true,
			// set the names of the template
			tmplNames: ["模板一"],
			// set the template contents
			tmplFilters: [template2]
		} // search options - define multiple search
	);

	function SaveEditedRows() {
		var grid = $("#testTypeList");
		var ids = grid.jqGrid('getDataIDs');
		for (var i = 0; i < ids.length; i++) {
			grid.jqGrid('setCell', ids[i], 0, grid.getCell(ids[i], "ischeck"));
		}
	}

	var timer
	$("#testParamSearch").on("keyup", function() {
		var self = this;
		if (timer) {
			clearTimeout(timer);
		}
		timer = setTimeout(function() {
			SaveEditedRows();
			$("#testTypeList").jqGrid('filterInput', self.value);
			setEditRow();
		}, 0);
	});
})

function AddRow() {
	$("#paramGroup").textbox("enable");
	formInit()
	$("#taskGroupList").trigger("reloadGrid");
	$("#testType").combobox("setValue", initSel);
	var $table = $("<table id='testTypeList'><table><div id='testTypeListPager'></div>");
	$("#myBox").empty().html($table);
	getPingList(null)

}

function formInit() {
	$('#taskGroupForm').form('load', {
		id: 0,
		paramGroup: '',
		cPreson: sessionStorage.getItem("realName"),
		meno: '',
	});
	currentgroupid = 0;
}

function SaveRow() {
	var paramId = '';
	var ids = $("#testTypeList").jqGrid('getDataIDs');
	for (var i = 0; i < ids.length; i++) {
		if ($("#testTypeList").getCell(ids[i], "ischeck") == 'Yes') {
			paramId += ids[i] + ",";
		}
	}
	var grid = $("#taskGroupList");
	var rowKey = grid.jqGrid('getGridParam', "selrow");
	var oldvalue = $("#taskGroupList").getCell(rowKey, "paramGroup");
	if (paramId == "") {
		$.messager.alert("提醒", "你还没有选测试参数", 'info');
		return;
	}
	var cTime = getCtime();
	var savestr = paramId.substr(0, paramId.length - 1);
	if ($('#taskGroupForm').form('enableValidation').form('validate')) {
		var testType = $("#testType").combobox("getValue");
		$.ajax({
			type: "post",
			url: IP + "UpdateParamGroupInfo",
			data: {
				savestr: savestr,
				session: session,
				id: $('#id').val(),
				type: testType,
				paramGroup: $("#paramGroup").val(),
				cPreson: $("#cPreson").val(),
				meno: $("#meno").val(),
			},
			dataType: "jsonp",
			jsonp: "callback",
			jsonpCallback: "resultHandler",
			success: function(json) {
				if (json.result = 200) {
					if ($('#id').val() == 0) {
						$("#taskGroupList").addRowData(json.id, {
							id: json.id,
							type: testType,
							paramGroup: $("#paramGroup").val(),
							cPreson: $("#cPreson").val(),
							meno: $("#meno").val(),
							cTime: cTime,
						}, '');
						insertopertlog('任务管理', '任务组管理', '新增', '', $("#paramGroup").val());
						$.messager.show({
							title: '提醒',
							msg: '任务参数组增加成功',
							timeout: 1300,
							showType: 'slide',
							style: {
								right: '',
								bottom: ''
							}
						});
					} else {
						$("#taskGroupList").setRowData($('#id').val(), {
							id: $('#id').val(),
							type: testType,
							paramGroup: $("#paramGroup").val(),
							cPreson: $("#cPreson").val(),
							meno: $("#meno").val(),
						}, '');
						insertopertlog('任务管理', '任务组管理', '修改', oldvalue, $("#paramGroup").val());
						$.messager.show({
							title: '提醒',
							msg: '任务参数组修改成功',
							timeout: 1300,
							showType: 'slide',
							style: {
								right: '',
								bottom: ''
							}
						});
					}
				} else {
					$.messager.alert('保存失败', json.message, 'error');
				}
				//保存成功后，重置控件，以免用户重复提交
				AddRow();
			}
		});
	}
}

function getCtime() {
	var curr_time = new Date();
	var strDate = curr_time.getFullYear() + "-";
	strDate += curr_time.getMonth() + 1 + "-";
	strDate += curr_time.getDate() + " ";
	strDate += curr_time.getHours() + ":";
	strDate += curr_time.getMinutes() + ":";
	strDate += curr_time.getSeconds();
	return strDate;

}

function EditRow() {
	$("#paramGroup").textbox("enable");
	var rowKey = $("#taskGroupList").jqGrid('getGridParam', "selrow");
	if (rowKey) {
		$('#taskGroupForm').form('load', {
			id: rowKey,
			paramGroup: $("#taskGroupList").getCell(rowKey, "paramGroup"),
			cPreson: $("#taskGroupList").getCell(rowKey, "cPreson"),
			meno: $("#taskGroupList").getCell(rowKey, "meno"),
		});
	} else {
		$.messager.alert('提醒', "没有选中行", 'info');
	}
}

//设置组对应测试参数
function getTaskGroupParam(d) {
	$.ajax({
		url: IP + "GetParamIDS?&session=" + session + "&pid=" + d,
		type: "Get",
		dataType: "jsonp",
		jsonp: "callback",
		jsonpCallback: "resultHandler",
		success: function(json) {
			for (var i = 0; i < json.length; i++) {
				$("#testTypeList").jqGrid('setCell', json[i].paramId, 0, 'Yes');
			}

			setEditRow();
		}
	})
}

function setEditRow() {
	var grid = $("#testTypeList");
	var ids = grid.jqGrid('getDataIDs');
	for (var i = 0; i < ids.length; i++) {
		//grid.jqGrid('setCell',ids[i],0,true);
		grid.jqGrid('editRow', ids[i]);
	}
}

function DeleteRow() {
	var grid = $("#taskGroupList");
	var rowKey = grid.jqGrid('getGridParam', "selrow");
	var oldvalue = $("#taskGroupList").getCell(rowKey, "paramGroup");
	if (rowKey) {
		$.messager.confirm('删除提醒', '你确认要删除' + $("#taskGroupList").getCell(rowKey, "paramGroup") + '组?', function(r) {
			if (r) {
				$.ajax({
					type: "post", // 与可以 "get"
					url: IP + "DeleteSigleParamGroupInfo?&callback=? ",
					data: {
						id: rowKey,
						session: session,
					},
					dataType: "jsonp",
					jsonp: "callback",
					jsonpCallback: "resultHandler",
					success: function(json) {
						if (json.result == 200) {
							$("#taskGroupList").delRowData(rowKey);
							insertopertlog('任务管理', '任务组管理', '删除', oldvalue, '');
							$.messager.show({
								title: '提醒',
								msg: '删除成功',
								timeout: 1300,
								showType: 'slide',
								style: {
									right: '',
									bottom: ''
								}
							});
						} else {
							$.messager.alert('删除失败', json.message, 'error');
						}
					}
				});
			}
		});
		AddRow();
	} else {
		$.messager.alert('提醒', "没有选中行", 'info');
	}
}

function change() {
	if (currentgroupid > 0) {
		var getRow = $("#taskGroupList").getRowData(currentgroupid);
		var testType = getRow.type;
		$("#testType").combobox("setValue", testType); //set select
	}
	var $table = $("<table id='testTypeList'><table><div id='testTypeListPager'></div>");
	$("#myBox").empty().html($table);
	var val = $("#testType").combobox('getValue');
	getTestParamList(val, currentgroupid);
}

//测试列表切换

function getTestParamList(t, isID) {

	switch (t) {
		case "Ping":
			getPingList(isID);
			break;
		case "TcpPing":
			getTcpingList(isID);
			break;
		case "NsLookUp":
			getDnsList(isID);
			break;
		case "FtpDownload":
			getFtpDownLoad(isID);
			break;
		case "FtpUpload":
			getFtpUpload(isID);
			break;

		case "WebDownload":
			getWebDownload(isID);
			break;
		case "HttpDownload":
			getHttpDownload(isID);
			break;
		case "TraceRoute":
			getTracekRoute(isID);
			break;
		case "RetrieveEmail":
			getRetrieveEMail(isID);
			break;
		case "SendEmail":
			getSendEmail(isID);
			break;
		default:
			$.messager.alert("提醒", "你请求的参数还没有生成。。。。", "info")

	}
}
//加载ping列表

function getPingList(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=Ping&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			formatter: 'checkbox',
			align: "center",
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			align: "center",
			hidden: true,
			width: 50
		}, {
			label: '目标地址',
			name: 'destination',
			width: 150
		}, {
			label: '超时',
			name: 'timeout',
			width: 70
		}, {
			label: '包大小',
			name: 'packsize',
			width: 70
		}, {
			label: '间隔时间',
			name: 'pinginterval',
			width: 70
		}, {
			label: '循环次数',
			name: 'count',
			width: 70
		}, {
			label: '开始时间',
			name: 'startTime',
			formatter: 'HH:MM',
			width: 70
		}, {
			label: '结束时间',
			name: 'endTime',
			formatter: 'HH:MM',
			width: 70
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',

	});
}
//加载tcpping列表；

function getTcpingList(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&session=" + session + "&paramtype=TcpPing",
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox'
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			align: "center",
			hidden: true,
			width: 50
		}, {
			label: '远程主机',
			name: 'destination',
			width: 90
		}, {
			label: '间隔时间',
			name: 'pinginterval',
			width: 70
		}, {
			label: '循环次数',
			name: 'count',
			width: 70
		}, {
			label: '端口',
			name: 'port',
			width: 70
		}, {
			label: '线路',
			name: 'ttl',
			width: 70
		}, {
			label: '超时',
			name: 'timeout',
			width: 60
		}, {
			label: '开始时间',
			name: 'startTime',
			formatter: 'HH:MM',
			width: 70
		}, {
			label: '结束时间',
			name: 'endTime',
			formatter: 'HH:MM',
			width: 70
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {
			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)

		},
		loadtext: '正在加载数据',

	})
}

function getFtpDownLoad(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=FtpDownload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox'
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '端口',
			name: 'port'
		}, {
			label: '路径',
			name: 'path'
		}, {
			label: '存储标志',
			name: 'storefileflag'
		}, {
			label: '本地标志',
			name: 'localactiveflag'
		}, {
			label: '用户',
			name: 'user'
		}, {
			label: '指定每天开始时间',
			name: 'startTime'
		}, {
			label: '指定每天结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',

	})
}

function getFtpUpload(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=FtpUpload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox'
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '端口',
			name: 'port'
		}, {
			label: '路径',
			name: 'path'
		}, {
			label: '存储标志',
			name: 'storefileflag'
		}, {
			label: '本地标志',
			name: 'localactiveflag'
		}, {
			label: '用户',
			name: 'user'
		}, {
			label: '本地随机文件',
			name: 'uploadrandomlocalfile'
		}, {
			label: '指定每天开始时间',
			name: 'startTime'
		}, {
			label: '指定每天结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',

	})
}

function getDnsList(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=Nslookup&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox'
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 70
		}, {
			label: '域名',
			name: 'domain',
			width: 150
		}, {
			label: '超时',
			name: 'timeout',
			width: 150
		}, {
			label: '开始时间',
			name: 'startTime',
			formatter: 'HH:MM',
			width: 150
		}, {
			label: '结束时间',
			name: 'endTime',
			formatter: 'HH:MM',
			width: 150
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',

	})
}

function getTracekRoute(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "/GetProbeParam?callback=?&paramtype=Ping&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			formatter: 'checkbox',
			align: "center",
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '最大网段',
			name: 'maxttl'
		}, {
			label: '开始时间',
			name: 'startTime'
		}, {
			label: '结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)

		},
		loadtext: '正在加载数据',

	});
}

function getWebDownload(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=WebDownload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox'
		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '路径深度(s)',
			name: 'pathdepth'
		}, {
			label: '检索配额',
			name: 'retrievalquota'
		}, {
			label: '递归',
			name: 'recursive'
		}, {
			label: '指定每天开始时间',
			name: 'startTime'
		}, {
			label: '指定每天结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',
	})
}

function getHttpDownload(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=HttpDownload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox',

		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '用户代理(s)',
			name: 'useragent'
		}, {
			label: '检索配额',
			name: 'retrievalquota'
		}, {
			label: '指定每天开始时间',
			name: 'startTime'
		}, {
			label: '指定每天结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',
	})
}

function getRetrieveEMail(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=HttpDownload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox',

		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '用户',
			name: 'user'
		}, {
			label: '端口',
			name: 'port'
		}, {
			label: '支持SSL',
			name: 'supportssl'
		}, {
			label: '邮件类型',
			name: 'mailtype'
		}, {
			label: '开始时间',
			name: 'startTime'
		}, {
			label: '结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',
	})
}

function getSendEmail(Id) {
	$("#testTypeList").jqGrid({
		url: IP + "GetProbeParam?callback=?&paramtype=HttpDownload&session=" + session,
		mtype: "Get",
		datatype: "jsonp",
		colModel: [{
			label: '选择',
			name: 'ischeck',
			edittype: "checkbox",
			width: 50,
			editable: true,
			align: "center",
			formatter: 'checkbox',

		}, {
			label: '序号',
			sorttype: 'integer',
			name: 'id',
			key: true,
			hidden: true,
			width: 50
		}, {
			label: '测试类型',
			name: 'testtype'
		}, {
			label: '单次测试超时(s)',
			name: 'timeout'
		}, {
			label: '目标地址',
			name: 'destination'
		}, {
			label: '服务端口',
			name: 'serverPort'
		}, {
			label: '用户',
			name: 'user'
		}, {
			label: '端口',
			name: 'port'
		}, {
			label: '上传文件',
			name: 'uploadlocalfile'
		}, {
			label: '邮件类型',
			name: 'mailfrom'
		}, {
			label: '接收人',
			name: 'mailrecipients'
		}, {
			label: '主题',
			name: 'subject'
		}, {
			label: '内容',
			name: 'content'
		}, {
			label: '附件大小',
			name: 'attachmentsize'
		}, {
			label: '附件类型',
			name: 'attachmenttype'
		}, {
			label: '开始时间',
			name: 'startTime'
		}, {
			label: '结束时间',
			name: 'endTime'
		}],
		loadonce: true,
		viewrecords: true,
		onselectrow: true,
		autowidth: true,
		height: 380,
		rowNum: -1,
		//page: 1,
		scroll: true,

		loadComplete: function(data) {

			if (Id) {
				getTaskGroupParam(Id);
				Id = null;
			} else {
				setEditRow();
			}
			var h = $("body").height();
			$("#testTypeList").jqGrid("setGridHeight", h - 173)
		},
		loadtext: '正在加载数据',
	})
}